import router from '../router';
import Vue from 'vue';
import errorVue from '../components/error.vue';



const errorConstructor = Vue.extend(errorVue);

let instance;
let layer=window.layer;
const initInstance = () => {
	instance = new errorConstructor({
		el: document.createElement('div')
	});
};
const openErrVue=(msg) => {
	if (!instance) {
		initInstance();
	}
	instance.msg=msg;
	document.body.appendChild(instance.$el);
	instance.show();
};



export const showError=(msg,type)=>{
	switch (type){
		case 1:
			//弹出层弹出错误信息
			layer.msg(msg);
			break;
		case 2:
			//弹出层覆盖整个页面
			openErrVue(msg);
			break;
		default:
			console.error(msg);
	}
}
